home *** CD-ROM | disk | FTP | other *** search
Java Source | 2003-07-02 | 1.4 KB | 46 lines |
-
- import java.sql.*;
-
- public class CategorieProdotto extends TabellaDB {
-
- public CategorieProdotto( Connection conn ) {
- super(conn);
- }
-
- void drop() throws SQLException {
- String sql = "DROP TABLE CATEGORIE_PRODOTTO";
- execute( sql );
- }
-
- void create() throws SQLException {
- String sql = "CREATE TABLE CATEGORIE_PRODOTTO ( " +
- "ID int(11) NOT NULL auto_increment, "+
- "CODICE int(11) NOT NULL, "+
- "DESCRIZIONE varchar(100) NOT NULL default '', "+
- "PRIMARY KEY (ID)"+
- ")";
- execute( sql );
- }
-
- void fill() throws SQLException {
- String sql = "INSERT INTO CATEGORIE_PRODOTTO ( CODICE, DESCRIZIONE ) VALUES (?,?)";
- int[] codici = { 10, 11, 12 };
- String[] categorie = { "Libri", "DVD", "CD Musicali" };
-
- PreparedStatement pstmt = conn.prepareStatement( sql );
-
- for( int i=0; i<categorie.length; i++ ) {
- int pos = 1;
-
- pstmt.setInt( pos++, codici[ i ] );
- pstmt.setString( pos++, categorie[ i ] );
-
- log( "CategorieProdotto: "+codici[ i ]+", "+categorie[ i ] );
-
- pstmt.executeUpdate();
- }
- pstmt.close();
- }
-
- }
-